//
//  XZRacsignHttpTool.m
//  TeYouDian
//
//  Created by mac on 17/3/28.
//  Copyright © 2017年 Mephsito. All rights reserved.
//

#import "XZRacsignHttpTool.h"
#import "RacsignHttpTool.h"

@implementation XZRacsignHttpTool

static void (^doNext)(id responseObject)=^(id responseObject){
    if ([[responseObject objectForKey:@"status"] isEqualToString:@"3100002"]) {
        [XZNotificationCenter postNotificationName:LoginAgaenNTF object:nil];
    }
};

/**用户信息*/
+ (RACSignal *)httpRequesWithUserRacsign:(BaseClientModel *)model{
    return [self returnRacSignalWithModel:model url:POSTurl isBaixun:YES];
}

+ (RACSignal *)httpRequesWithModel:(BaseClientModel *)model image:(UIImage *)image{
    
    NSDictionary *params = @{@"bxjson":model.modelToJSONString};
    NSData *data1=[NSData data];
    data1 = UIImageJPEGRepresentation(image, 0.5);
    return [[RacsignHttpTool post2racWthURL:POSTurl params:params imageArr:@[data1] isSingleImage:YES] replayLazily];
}

#pragma mark  - Founction

+ (RACSignal *)returnRacSignalWithModel:(BaseClientModel *)model
                                    url:(NSString *)url
                             headParams:(NSDictionary *)headParams{
    NSDictionary *dict=[model getHttpParams];
    return [[[RacsignHttpTool post2racWthURL:url headParams:headParams params:dict]doNext:doNext]replayLazily];
}

+ (RACSignal *)returnRacSignalWithModel:(BaseClientModel *)model
                                    url:(NSString *)url
                               isBaixun:(BOOL)isBaixun{
    
    NSDictionary *params = @{@"bxjson":model.modelToJSONString};
    NSDictionary *dict=isBaixun?params:[model getHttpParams];
    return [[[RacsignHttpTool post2racWthURL:url params:dict] doNext:doNext]replayLazily];
}



@end
